package com.mxpio.boot.excel.api.conf;

import com.mxpio.framework.security.base.service.*;
import com.mxpio.framework.system.service.PojoDictParseService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @创建人 gewenzhen
 * @创建时间 2024/12/31
 * @描述
 */
@Configuration
@ConditionalOnProperty(name = "mxpio.cloudModel", havingValue = "true")
public class ExcelCloudServiceConfig {
    @DubboReference
    UserService userService;
    @DubboReference
    DataResourceService dataResourceService;
    @DubboReference
    PojoDictParseService pojoDictParseService;

    @Bean
    @ConditionalOnMissingBean(UserService.class)
    public UserService remoteUserService() {
        if(userService == null){
            System.out.println("userService is null");
        }
        return userService;
    }

    @Bean
    @ConditionalOnMissingBean(DataResourceService.class)
    public DataResourceService remoteDataResourceService() {
        return dataResourceService; // 注入远程服务
    }

    @Bean
    @ConditionalOnMissingBean(PojoDictParseService.class)
    public PojoDictParseService remotePojoDictParseService() {
        return pojoDictParseService; // 注入远程服务
    }
}
